<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>
<body>
    <div id="app">
        <!-- 循环数组 -->
        <ul>
            <li v-for="(item, index) in arr">{{item}} --- {{index}}</li>
        </ul>
        数组的length是<b>{{arr.length}}</b>
        <!-- 循环数字 -->
        <ul>
            <li v-for="(item, index) in 10">{{item}} --- {{index}}</li>
        </ul>


        <button @click="appendFormAttr">添加属性</button>
        <!-- 循环对象 -->
        <ul>
            <li v-for="(item, index) in formData">{{item}} --- {{index}}</li>
        </ul>

        <!--
            循环字符串
            length
         -->
        <ul>
            <li v-for="(item, index) in 'hello-world'">{{item}} --- {{index}}</li>
        </ul>
    </div>

    <script src="./vue.js"></script>
    <script>
        // 数据驱动
        let myApp = new Vue({
            el: '#app',
            data: {
                arr: ['html', 'css', 'js', 'java', 'php'],

                // 对象初始化
                // 对象-如果第一次渲染完成以后
                // 再次添加对象属性之外的键值
                // 那么不参与动态渲染
                // 解决方案是使用vue自带api的$set
                formData: {
                    name: 'tom',
                    age: '18',
                    height: 180,
                    money: 9.9
                }
            },
            methods: {
                appendFormAttr () {
                    // 
                    this.$set(this.formData, 'car', 'bwm')
                }
            }
        })
    </script>
</body>
</html>